package com.redis.Util;


import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import redis.clients.jedis.Jedis;

import javax.annotation.Resource;

@Controller
public class Test {
    public void Test1(){
        Jedis jedis = new Jedis("192.168.36.129", 6379);
        jedis.auth("123456");
        System.out.println("--------------");
        System.out.println(jedis.ping());
        String key1 = "user:2";
        int num = 1;
        if (jedis.exists(key1)) {
            jedis.incrBy(key1, num);
            int v = Integer.parseInt(jedis.get(key1));
            if (v <= 0) {
                jedis.del(key1);
            }
        } else {
            jedis.set(key1, "1");
        }

    }

}
